//
//  BBAlertView.swift
//  BusinessBao
//
//  Created by Chen on 2017/7/20.
//  Copyright © 2017年 Chen. All rights reserved.
//

import UIKit

class BBAlertView: NSObject {
    
    /// 显示一个alertView  类方法
    ///
    /// - Parameters:
    ///   - ViewController: 需显示alert的控制器
    ///   - title: alert的title
    ///   - message: alert的message
    ///   - buttonTitles: alert上的按钮名数组
    ///   - selectBlock: 点击按钮的回调
    class func alertViewShow(In ViewController: UIViewController,
                             title: String,
                             message: String,
                             buttonTitles: Array<String>,
                             selectBlock: @escaping ((_ index: Int) -> ())) {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
        
        for i in 0..<buttonTitles.count {
            let action = UIAlertAction(title: buttonTitles[i], style: .default, handler: { (action) in
                selectBlock(i)
            })
            alertController.addAction(action)
        }
        
        ViewController.present(alertController, animated: true, completion: nil)
    }
}
